#define _CRT_SECURE_NO_WARNINGS 1
#include"sort.h"

void test1()
{
	int a[10] = { 6,1,2,7,9,3,4,5,10,8 };
	/*Bubblesort(a, 10);
	Printarr(a, 10);
	Insertsort(a, 10);
	Printarr(a, 10);*/
	Shellsort(a, 10);
	Printarr(a, 10);
	Selectsort(a, 10);
	Printarr(a, 10);
	Quiksort(a, 0, 9);
	Printarr(a, 10);


}

void TestOP()
{
	srand(time(0));
	const int N = 100000;
	int* a1 = (int*)malloc(sizeof(int) * N);
	int* a2 = (int*)malloc(sizeof(int) * N);
	int* a3 = (int*)malloc(sizeof(int) * N);
	int* a4 = (int*)malloc(sizeof(int) * N);
	int* a5 = (int*)malloc(sizeof(int) * N);
	

	for (int i = 0; i < N; i++)
	{
		a1[i] = rand();
		a2[i] = rand();
		a3[i] = rand();
		a4[i] = rand();
		a5[i] = rand();
		

	}
	int begin1 = clock();
	Insertsort(a1, N);
	int end1 = clock();
	int begin2 = clock();
	Bubblesort(a2, N);
	int end2 = clock();
	int begin3 = clock();
	Shellsort(a3, N);
	int end3 = clock();
	int begin4 = clock();
	Quiksort(a4, 0,N-1);
	int end4 = clock();
	int begin5 = clock();
	Heapsort(a5, N);
	int end5 = clock();

	printf("Insertsort:%d\n", end1 - begin1);
	printf("Bubblesort:%d\n", end2 - begin2);
	printf("Shellsort:%d\n", end3 - begin3);
	printf("Qucksort:%d\n", end4 - begin4);
	printf("Heapsort:%d\n", end5 - begin5);

	free(a1);
	free(a2);
	free(a3);
	free(a4);
	free(a5);
	
}



int main()
{
	//test1();
	TestOP();
	return 0;
}